<!DOCTYPE html>
<html lang="en"

      xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">

  <title>图书编辑</title>
  <style>
    nav {
      font-size: 1.5rem;
      background-color: #21D4FD;
      background-image: -webkit-linear-gradient(19deg, #21D4FD 0%, #B721FF 100%);
      background-image: -moz-linear-gradient(19deg, #21D4FD 0%, #B721FF 100%);
      background-image: -o-linear-gradient(19deg, #21D4FD 0%, #B721FF 100%);
      background-image: linear-gradient(19deg, #21D4FD 0%, #B721FF 100%);
    }
    h1 {
      font-size: 2rem;
    }
    li {
      margin: 10px 20px;
    }
    body {
      /*             background-image: url("../static/img/2.jpg"); */
      background-size: cover;
    }


  </style>
</head>
<body>

<!--图书编辑页面-->
<nav class="navbar navbar-expand-sm bg-primary navbar-dark">
  <ul class="navbar-nav">
    <li>
      <h1><a th:href="@{/web/toindex(admin='admin')}" style="color: white; text-decoration: none">恋文图书管理系统</a></h1>
    </li>
    <li class="nav-item">
      <a class="nav-link" th:if="${session.user.admin} eq '1'" th:href="@{/book/showbook}">图书管理</a>
      <a class="nav-link" th:if="${session.user.admin} eq '0'" th:href="@{/book/showbook1}">图书信息</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" th:if="${session.user.admin} eq '1'" th:href="@{/user/showuser}">读者管理</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" th:if="${session.user.admin} eq '1'" >借还管理</a>
      <a class="nav-link" th:if="${session.user.admin} eq '0'" >借还记录</a>
    </li>
  </ul>


  <div class="text-white" style="font-size: medium; position: absolute; bottom: 30px; right: 40px">
    <div class="dropdown">
      <a class="dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
         th:text="${session.user.username}+', 您好'">
      </a>
      <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
        <a th:if="${session.user.admin} eq '0'" class="dropdown-item" th:href="@{/web/tofollowlist}" >收藏列表</a>
        <a th:if="${session.user.admin} eq '0'" class="dropdown-item" th:href="@{/user/userinfo(username = ${session.user.username})}" >个人信息</a>
        <a th:if="${session.user.admin} eq '0'" class="dropdown-item" th:href="@{/web/toupdatepw}">修改密码</a>
        <a class="dropdown-item" th:href="@{/user/logout}">注销</a>      </div>
    </div>
  </div>
</nav>


<div class="container">
  <form th:action="@{/book/editbook}" method="post">

    <table class="table">
      <input type="text" hidden id="bookid" name="bookid" th:value="${book.bookid}">
      <tr>
        <th>书名</th>
        <td th:if="${session.user.admin} eq '0'" th:text="${book.bookname}"></td>
        <td th:if="${session.user.admin} eq '1'"><input type="text" class="form-control" id="bookname" name="bookname" th:value="${book.bookname}"></td>
      </tr>
      <tr>
        <th>作者</th>
        <td th:if="${session.user.admin} eq '0'" th:text="${book.author}"></td>
        <td th:if="${session.user.admin} eq '1'"><input type="text" class="form-control" id="author" name="author" th:value="${book.author}"></td>
      </tr>
      <tr>
        <th>出版社</th>
        <td th:if="${session.user.admin} eq '0'" th:text="${book.publisher}"></td>
        <td th:if="${session.user.admin} eq '1'"><input type="text" class="form-control" id="publisher" name="publisher" th:value="${book.publisher}"></td>
      </tr>

      <tr>
        <th>简介</th>
        <td th:if="${session.user.admin} eq '0'" th:text="${book.summary}"></td>
        <td th:if="${session.user.admin} eq '1'"><input type="text" class="form-control" id="summary" name="summary" th:value="${book.summary}"></td>
      </tr>
      <tr>
        <th>价格</th>
        <td th:if="${session.user.admin} eq '0'" th:text="${book.price}"></td>
        <td th:if="${session.user.admin} eq '1'"><input type="text" class="form-control" id="price" name="price" th:value="${book.price}"></td>
      </tr>
      <tr>
        <th>ISBN</th>
        <td th:if="${session.user.admin} eq '0'" th:text="${book.isbn}"></td>
        <td th:if="${session.user.admin} eq '1'"><input type="text" class="form-control" id="isbn" name="isbn" th:value="${book.isbn}"></td>
      </tr>

      <tr>
        <th>语言</th>
        <td th:if="${session.user.admin} eq '0'" th:text="${book.language}"></td>
        <td th:if="${session.user.admin} eq '1'"><input type="text" class="form-control" id="language" name="language" th:value="${book.language}"></td>
      </tr>

      <tr>
        <th>出版日期</th>
        <td th:if="${session.user.admin} eq '0'" th:text="${book.pubdate}"></td>
        <td th:if="${session.user.admin} eq '1'"><input type="text" class="form-control" id="pubdate" name="pubdate" th:value="${#dates.format(book.pubdate,'yyyy-MM-dd')}"></td>
      </tr>
      <tr>
        <th>书架号</th>
        <td th:if="${session.user.admin} eq '0'" th:text="${book.pressmark}"></td>
        <td th:if="${session.user.admin} eq '1'"><input type="text" class="form-control" id="pressmark" name="pressmark" th:value="${book.pressmark}"></td>
      </tr>
      <tr>
        <th>分类号</th>
        <td th:if="${session.user.admin} eq '0'" th:text="${book.typeId}"></td>
        <td th:if="${session.user.admin} eq '1'"><input type="text" class="form-control" id="typeId" name="typeId" th:value="${book.typeId}"></td>
      </tr>

      <tr>
        <th>状态</th>
        <td th:if="${session.user.admin} eq '0'" th:switch="${book.status}">
          <span th:case="0">在馆</span>
          <span th:case="1">已借出</span>
        </td>
        <td th:if="${session.user.admin} eq '1'"><input type="text" class="form-control" id="stock" name="stock" th:value="${book.status}"></td>
      </tr>
    </table>
    <a th:if="${session.user.admin} eq '1'" th:href="@{/book/showbook}" class="btn btn-outline-primary btn-lg">返&nbsp;&nbsp;&nbsp;&nbsp;回</a>

    <a th:if="${session.user.admin} eq '0'" th:href="@{/book/showbook1}" class="btn btn-outline-primary btn-lg">返&nbsp;&nbsp;&nbsp;&nbsp;回</a>
    <span th:if="${session.user.admin} eq '1'"><button  type="submit" class="btn btn-outline-primary btn-lg">提交</button></span>

  </form>
</div>

</body>
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
</html>